package com.ruoyi.web.controller.common;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.TestMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/admin")
public class AdminController {

    @Resource
    public TestMapper testMapper;

    @RequestMapping("/ok")
    public AjaxResult ok(@RequestParam(required = false) String type){
            if(StringUtils.isNotNull(type) && type.equals("db")){
                QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper();
                queryWrapper.lambda().eq(SysUserRole::getRoleId,1);
                List<SysUserRole> sysUserRole = testMapper.selectList(queryWrapper);
                return AjaxResult.success(sysUserRole.get(0).toString());
            }
        return  AjaxResult.success("ok");
    }
}
